package com.whj.wkpt.mapper;

import com.whj.wkpt.entity.TaskReview;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TaskReviewMapper {
    
    TaskReview findById(Long reviewId);
    
    @Insert("INSERT INTO task_reviews(task_id, employer_id, freelancer_id, content, rating, review_time, create_time, update_time) " +
            "VALUES(#{taskId}, #{employerId}, #{freelancerId}, #{content}, #{rating}, #{reviewTime}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "reviewId")
    int insert(TaskReview taskReview);
    
    @Update("UPDATE task_reviews SET task_id=#{taskId}, employer_id=#{employerId}, freelancer_id=#{freelancerId}, " +
            "content=#{content}, rating=#{rating}, review_time=#{reviewTime}, update_time=#{updateTime} " +
            "WHERE review_id=#{reviewId}")
    int update(TaskReview taskReview);
    
    @Delete("DELETE FROM task_reviews WHERE review_id = #{reviewId}")
    int deleteById(Long reviewId);
    
    List<TaskReview> findAll();
    
    List<TaskReview> findByTaskId(Long taskId);
}